package cn.chinaunicom.config;

import cn.chinaunicom.bean.Person;
import cn.chinaunicom.service.PersonService;
import org.springframework.context.annotation.*;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * @author xuwenyuan
 * @date 2020-02-11
 *
 * 配置类（相当于配置文件xml）
 */

//@ComponentScan(value = {"cn.chinaunicom"}, excludeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes={Controller.class, Service.class})
//})

@Configuration
//@ComponentScan(value = "cn.chinaunicom", includeFilters = {
//    @Filter(type = FilterType.ANNOTATION, classes = {Controller.class, Service.class})
//    }, useDefaultFilters = false
//)
@ComponentScans(
        value = {
                @ComponentScan(value = "cn.chinaunicom", includeFilters = {
                        //@Filter(type = FilterType.ANNOTATION, classes = {Controller.class}),
                        //@Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {PersonService.class}),
                        @Filter(type = FilterType.CUSTOM,classes = {MyTypeFilter.class})

                    }, useDefaultFilters = false
                )
        }
)
public class MainConfig {
    /**
     * @Bean注解，加入spring容器，
     * 类型为返回值类型，这里是Person,id默认是方法名person，可以通过@Bean("id")进行修改
     * @return
     */
    @Bean("person")
    public Person person(){
        return new Person(20,"lishi");
    }
}
